﻿//using Psi.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Psi.Core.Models
{
    /// <summary>
    /// 广告分类管理
    /// </summary>
    [Table("Category")]
    public class Category : Entity
    {
        public Category()
        {
            //Sort = DateHelper.DateTimeToStamp();
            Status = 1;
            Mod = 0;
            ParentID = 0;
        }

        /// <summary>
        /// 标题
        /// </summary>
        [Display(Name = "标题")]
        [StringLength(50, ErrorMessage = "必须少于{0}个字")]
        public string Title { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        [Display(Name = "英文名")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字")]
        public string Content { get; set; }
        /// <summary>
        /// 缩略图
        /// </summary>
        [Display(Name = "缩略图")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字符")]
        public string Image { get; set; }
        /// <summary>
        /// 链接
        /// </summary>
        [Display(Name = "链接")]
        [StringLength(255, ErrorMessage = "必须少于{0}个字符")]
        public string Url { get; set; }
        ///// <summary>
        ///// 层级
        ///// </summary>
        //public byte Lvl { get; set; }
        /// <summary>
        /// 排序
        /// <remarks>0为默认排序</remarks>
        /// </summary>
        [Display(Name = "排序")]
        [Required(ErrorMessage = "*")]
        public int Sort { get; set; }
        /// <summary>
        /// 状态
        /// <remarks>删除-2 关闭-1 审核/草稿0 发布1</remarks>
        /// </summary>
        [Display(Name = "状态")]
        public int Status { get; set; }
        //[Display(Name = "引用数")]
        //public int Num { get; set; }
        //[Display(Name = "上层ID")]
        //public string UpID { get; set; }
        //[Display(Name = "上层Name")]
        /// <summary>
        /// 默认0宽屏 页1 页2
        /// <remarks></remarks>
        /// </summary>
        //[Display(Name = "页面ID")]
        //public byte Page { get; set; }
        /// <summary>
        /// 0默认 1文章 2产品 3广告 4页面 5菜单
        /// </summary>
        [Display(Name = "模块ID")]
        public byte Mod { get; set; }
        //public string ParentName { get; set; }
        public int ParentID { get; set; }

        [ForeignKey("CatId")]
        public virtual ICollection<Article> Articles { get; set; }
        [ForeignKey("CatId")]
        public virtual ICollection<Banner> Banners { get; set; }
        [ForeignKey("CatId")]
        public virtual ICollection<Product> Products { get; set; }
    }
}
